package com.dyz.leetcode._01_array;

public class _283_moveZeroes {
    public void moveZeroes(int[] nums) {
        int n = nums.length;
        if(n<=1){return;}
        int start = 0;
        int end = 0;
        while(end<n){
            if(nums[end]!=0){
                int temp = nums[start];
                nums[start] = nums[end];
                nums[end] = temp;
                start++;
            }
            end++;
        }
    }
    public void moveZeroes1(int[] nums) {
        int n = nums.length;
        if(n<=1){return;}
        int start = 0;
        int end = 0;
        while(end<n){
            if(nums[end]!=0){
                nums[start] = nums[end];
                start++;
            }
            end++;
        }
        for(int i = start; i<n;i++){
            nums[i]=0;
        }
    }
}
